//************************************************************
//	COPYRIGHT 2011 Birthin' Hips - ALL RIGHTS RESERVED
//************************************************************
//
//	$Id: MessageFinalizer.java$
//
//	$Date: 12/13/11$
//
//	Reason: 'Main' thread. Creates ProducerThread and ConsumerThread. Pulls and verifies messages
//			from the write queue. Verifies by asking for verification from ProducerThread. Sends
//			information to Logger for logging in external file.
//
//*************************************************************

/**
* 
* @author Elysia Haight, Ross Kahn, Colton Presler
* 
* @date	12/13/11
*/

package com;

//==============================================================
public class MessageFinalizer {
	
	private static final long PRODUCER_DELAY = 5;	// Number of milliseconds the ProducerThread delays between actions
	private static final long CONSUMER_DELAY = 10;	// Number of milliseconds the ConsumerThread delays between actions

	/**
	 *  Entry point into program. Creates and starts ProducerThread and ConsumerThread, instantiates Logger, and
	 *  then loops to read and verify messages coming off the write queue
	 * @param args		Not used
	 */
	//----------------------------------------------------------
	public static void main(String[] args) {
		
		ProducerThread producer = new ProducerThread(PRODUCER_DELAY);
		Thread pThread = new Thread(producer);
	
		ConsumerThread consumer = new ConsumerThread(CONSUMER_DELAY);
		Thread cThread = new Thread(consumer);
		
		Logger logger = new Logger();
	
		pThread.start();
		cThread.start();
		
		while(true){
			Message msg = MessageQueue.pullFromWriteQueue();
		
			logger.log(msg, producer.verify(msg));
			
		}
	}

}
